package com.app.util;

import com.suncnpap.system.model.TMakeMake;
import com.suncnpap.system.service.TMakeMakeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

@Component
public class ScheduledTask {

    @Autowired
    private TMakeMakeService tMakeMakeService;

    @Scheduled(cron = "0 0/10 * * * ?")
    public void task(){
        List<TMakeMake> makeList = tMakeMakeService.getMakeList();
        for (TMakeMake list:makeList){
            if(new Date().equals(list.getOverdueDate())){
                Integer tMakeMake=tMakeMakeService.automaticMake(list.getId());
                if(tMakeMake>0){
                    System.out.print("自动取消成功");
                }
            }
        }
    }
}
